package com.hxut.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hxut.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class BookServiceTestCase {
    @Autowired
    private Book book;
    @Autowired
    private BookService bookService;
    @Test
    void testGetById(){
        System.out.println(bookService.getById(4));
    }
    /**
     * 测试增加
     */
    @Test
    void testSave(){
        book.setType("测试数据123");
        book.setName("测试数据123");
        book.setDescription("测试数据123");
        bookService.save(book);
    }

    /**
     * 测试更新
     */
    @Test
    void testUpdate(){
        book.setId(5);
        book.setType("测试数据123aaa");
        book.setName("测试数据123sds");
        book.setDescription("测试数据123aaa");
        bookService.update(book);
    }

    /**
     * 测试删除
     */
    @Test
    void testDelete(){
        System.out.println(bookService.delete(19));
    }

    /**
     * 测试查询全部
     */
    @Test
    void testGetAll(){
        System.out.println(bookService.getAll());
    }

    /**
     * 测试分页
     */
    @Test
    void testGetPage(){

        IPage<Book> page = bookService.getByPage(2, 5);
        System.out.println(page.getCurrent());//当前的页码
        System.out.println(page.getSize());//每页多少数据
        System.out.println(page.getTotal());//总记录条数
        System.out.println(page.getRecords());//数据
    }




}
